package com.etc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.etc.dao.UserMapper;
import com.etc.entity.Job;
import com.etc.entity.LayUiData;
import com.etc.entity.User;
import com.etc.service.UserService;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User getUser(int userId) {
		// TODO Auto-generated method stub
		return userMapper.getUser(userId);
	}
	@Override
	public User judgeUser(User user) {
		// TODO Auto-generated method stub
		return userMapper.judgeUser(user);
	}
	@Override
	public boolean addUser(User user) {
		// TODO Auto-generated method stub
		return userMapper.addUser(user) > 0;
	}
	@Override
	public boolean update(User user) {
		// TODO Auto-generated method stub
		return userMapper.updateUser(user) > 0;
	}
	@Override
	public boolean delUser(int userId) {
		// TODO Auto-generated method stub
		return userMapper.delUser(userId) > 0;
	}

	@Override
	public Integer getUserCount() {
		// TODO Auto-generated method stub
		return userMapper.getUserCount();
	}

	@Override
	public List<User> getUsers(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		return userMapper.getUsers(start, limit, strLike);
	}

	@Override
	public LayUiData<User> getUserByLike(int page, int limit, String strLike) {
		// TODO Auto-generated method stub
		int start = (page - 1) * limit;
		LayUiData<User> laydata = new LayUiData<User>();
		List<User> list = userMapper.getUsers(start, limit, strLike);
		laydata.setCode(0);
		laydata.setMsg("");
		laydata.setCount(userMapper.getUserCount());
		laydata.setData(list);
		System.out.println("laydata:" + laydata);
		return laydata;
	}
}
